/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nuboat.easyjsf.entity;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

/**
 *
 * @author nuboat
 */
@Entity
@Table(name = "USERS")
@NamedQueries({
    @NamedQuery(name = "UsersEntity.findAll", query = "SELECT i FROM UsersEntity i"),
    @NamedQuery(name = "UsersEntity.findByUserid", query = "SELECT i FROM UsersEntity i WHERE i.userid = :userid"),
    @NamedQuery(name = "UsersEntity.findByUsername", query = "SELECT i FROM UsersEntity i WHERE i.username = :username")})
public class UsersEntity extends BasedEntity {

    private static final long serialVersionUID = 1274002424416L;

    @TableGenerator(    name = "SEQ_USER",
        table = "EASYJSFSEQ",
        pkColumnName = "NAMESEQ",
        valueColumnName = "VALUESEQ",
        pkColumnValue = "SEQ_USER",
        initialValue = 10000,
        allocationSize = 100)

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator="SEQ_USER")
    @Basic(optional = false)
    @Column(name = "USERID", nullable = false)
    private Long userid;
    @Basic(optional = false)
    @Column(name = "USERNAME", length = 64, nullable = false)
    private String username;

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userid != null ? userid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UsersEntity)) {
            return false;
        }
        UsersEntity other = (UsersEntity) object;
        if ((this.userid == null && other.userid != null) || (this.userid != null && !this.userid.equals(other.userid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.nuboat.easyjsf.UsersEntity[id=" + getUserid() + "]";
    }

    public Long getUserid() {
        return userid;
    }

    public void setUserid(Long userid) {
        this.userid = userid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
